package com.gitee.feizns.quickstart.mybatis.flex.spring.boot.autoconfigure;

import com.gitee.feizns.quickstart.domain.query.Relationship;
import com.gitee.feizns.quickstart.jackson.JsonUtils;
import com.gitee.feizns.quickstart.mybatis.flex.query.MybatisFlexRelationship;
import com.mybatisflex.core.FlexGlobalConfig;
import com.mybatisflex.core.handler.JacksonTypeHandler;
import com.mybatisflex.spring.boot.MyBatisFlexCustomizer;
import org.springframework.context.annotation.Configuration;

/**
 * MyBatis Flex 自动配置
 * @author feizns
 * @since 2025/2/17
 */
@Configuration
public class MybatisFlexAutoConfiguration implements MyBatisFlexCustomizer {

    @Override
    public void customize(FlexGlobalConfig config) {
        //设置jackson配置
        JacksonTypeHandler.setObjectMapper(JsonUtils.getObjectMapper());
        //设置关系查询生成器
        Relationship.generator.set(MybatisFlexRelationship::new);
    }

}
